package com.delivery.deliverysystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.delivery.deliverysystem.dao.SysAuthorityMapper;
import com.delivery.deliverysystem.pojo.DO.SysAuthority;
import com.delivery.deliverysystem.service.SysAuthorityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 事务服务类
 * @author Bernie_fang
 * @date 2021/3/12 15:02
 */
@Service
public class SysAuthorityServiceImpl implements SysAuthorityService {

    @Autowired
    private SysAuthorityMapper authorityMapper;

    /**
     * 新增权限角色
     * @param sysAuthority
     * @return
     */
    @Override
    public int insertSysAuthority(SysAuthority sysAuthority) {
        return authorityMapper.insert(sysAuthority);
    }

    /**
     * 修改权限角色
     * @param sysAuthority
     * @return
     */
    @Override
    public int updateSysAuthority(SysAuthority sysAuthority) {
        return authorityMapper.updateById(sysAuthority);
    }

    /**
     * 删除权限角色
     * @param id
     * @return
     */
    @Override
    public int deleteSysAuthority(String id) {
        return authorityMapper.deleteById(id);
    }

    /**
     * 查找一个权限角色
     * @param authorityRole
     * @return
     */
    @Override
    public SysAuthority findSysAuthority(String authorityRole) {
        QueryWrapper wrapper = new QueryWrapper<SysAuthority>();
        wrapper.eq("authority_role",authorityRole);
        return authorityMapper.selectOne(wrapper);
    }

    /**
     * 查找一个权限角色
     * @param authorityId
     * @return
     */
    public SysAuthority findSysAuthority(Integer authorityId) {
        QueryWrapper wrapper = new QueryWrapper<SysAuthority>();
        wrapper.eq("id",authorityId);
        return authorityMapper.selectOne(wrapper);
    }

    /**
     * 查找多个权限角色
     * @return
     */
    @Override
    public List<SysAuthority> querySysAuthority() {
        return null;
    }

}
